/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ldtwo.GoTTS;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseWheelEvent;
import java.io.File;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import static org.ldtwo.GoTTS.Languages.LA_LANGUAGE;

/**
 *
 * @author ldtwo
 */
public class EditorPanel extends javax.swing.JPanel implements DocumentListener {
    
    public String tabName = "English";
    public File file = null;
    public String la_ = "en_gb";
    public boolean modified = false;
    public boolean monitor = false;
    public int fontSize = 4;

    /**
     * Creates new form EditorPanel
     */
    public EditorPanel() {
        initComponents();
        txt.getDocument().addDocumentListener(this);
        addMouseWheelListener(new MouseAdapter() {
            
            @Override
            public void mouseWheelMoved(MouseWheelEvent e) {
                MainFrame.ths.tabPaneMouseScroll(e);
            }
            
        });
    }

    public String getLanguage() {
        return LA_LANGUAGE.get(la_);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        txt = new javax.swing.JTextArea();

        setLayout(new java.awt.GridLayout(1, 0));

        txt.setColumns(20);
        txt.setLineWrap(true);
        txt.setRows(5);
        txt.setText("Thank you for trying JGoogle TTS a.k.a. GoTTS.\n\nhttp://code.google.com/p/jgoogletexttospeech/\n\nHello, how are you today?\nBonjour, comment allez-vous aujourd'hui?\nHola, ¿cómo estás hoy?\nHallo, wie geht es Ihnen heute?\nHej, hur mår du idag?\n你好\n\n\n\n");
        jScrollPane1.setViewportView(txt);

        add(jScrollPane1);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JTextArea txt;
    // End of variables declaration//GEN-END:variables

    @Override
    public void insertUpdate(DocumentEvent e) {
        
        if (monitor&&!modified) {
            modified = true;
            updateTab();
        }
    }
    
    @Override
    public void removeUpdate(DocumentEvent e) {
        
        if (monitor&&!modified) {
            modified = true;
            updateTab();
        }
    }
    
    @Override
    public void changedUpdate(DocumentEvent e) {
        if (monitor&&!modified) {
            modified = true;
            updateTab();
        }
    }
    public void updateTab(){}
}
